



import React,{PureComponent,Component} from 'react'
import './App.css'
class App extends Component{
  state={
   msg:'app中的state初始值'
  }

  handleClick = ()=>{
    this.setState({
      msg:'点击改变的'
    })
  }
  render(){
   return (
    <div className="outerBox" id="outerBox">
    <div className="innerBox">
      <h1>{this.state.msg}</h1>
      <button onClick={this.handleClick}>更新视图</button>
    </div>
  </div>
   )
  }

  getSnapshotBeforeUpdate(props,state){
    // 计算 值
    return 200;
  }
  componentDidUpdate(props,state,snapshot){
    document.getElementById("outerBox").scrollTop = snapshot;
  }
}



export default App;

